<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p>标签上可以使用ref给DOM（或者组件）命名，使用 vue.$refs.ref名称 可以获取到DOM（或者组件）</p>
    <main id="app">
        <p ref="p1"></p>
        <button @click="handleClick">点击</button>
    </main>
</body>
<script src="../vue.min.js"></script>
<script>
    // let p = document.querySelector("#p1");

    let vue = new Vue({
        el: "#app",
        data() {
            return {
                person: {
                    name: "Hydra"
                }
            }
        },
        methods: {
            handleClick() {
                console.log(this.person.name);
                this.$refs.p1.innerText = this.person.name;
                // p.innerText 
            }
        }
    })
</script>

</html>